function pe16(limit) {
    var result = [1];
    var power = function() {
        var tmp1, tmp2, tmp3, tmp4=0;
        for(var i=0; i<result.length; i++) {
            tmp1 = result[i];
            tmp2 = tmp1*2 + tmp4;
            tmp3 = tmp2%10;
            tmp4 = (tmp2 - tmp3)/10;
            result[i] = tmp3;
        }
        if(tmp4) {
            result.push(tmp4)
        }
    }
    
    for(var i=1; i<=limit; i++) {
        power();
    }
    return eval(result.join("+"));
    return result.reverse().join("");
}


var t = new Date().getTime();
print(pe16(1000))
print("Time used: " + (new Date().getTime()-t)/1000 + "s");
